package com.sws.orderMS.pojo;

public class Product {

	private long id;			// 商品id
	private String code;		// 商品代号
	private String name;		// 商品名称
	private String type;		// 商品类型
	private String description;	// 商品描述
	private double price;		// 商品单价
	private int qty;			// 库存
	
	public Product() {
	}
	
	public Product(long id, String code, String name, String type, double price, int qty, String description) {
		this.id = id;
		this.code = code;
		this.name = name;
		this.type = type;
		this.price = price;
		this.qty = qty;
		this.description = description;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public int getQty() {
		return qty;
	}

	public void setQty(int qty) {
		this.qty = qty;
	}
	
	// 如果商品id相同则认为是同一件商品
	public boolean equals(Object obj) {
		if (!(obj instanceof Product)) {
			return false;
		}
		Product product = (Product)obj;
		return this.id == product.getId();
	}
	
	public int hashCode() {
		String str = id + "";
		return str.hashCode();
	}
	
	public String toString() {
		return "[商品代号:" + code +
			   ", 商品名称:" + name +
			   ", 类型:" + type +
			   ", 描述:" + description +
			   ", 单价:" + price + "元" +
			   ", 库存:" + qty + "]";
	}
	
}
